package dt.day03;

import java.util.*;

public class Test {
    static Map<String , Integer> map = new HashMap<>();
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        map.put("张三",3);
        map.put("李四",5);
        map.put("王五",7);
        values();
        System.out.println("请输入学生姓名:");
        String name = sc.next();
        if (map.containsKey(name)){
            System.out.println("有此学生!");
            System.out.println("请输入成绩:");
            int score = sc.nextInt();
            map.put(name,score);
            System.out.println("--------成绩修改后--------");
            values();
        }else {
            System.out.println("查无此人！");
        }
        sc.close();
    }
    public static void values(){
        Set<String> allkey = map.keySet();
        Iterator<String> iterator = allkey.iterator();
        System.out.println("----------学生成绩----------");
        while (iterator.hasNext()){
            String key = iterator.next();
            System.out.println(key+":"+map.get(key));
        }
    }
}
